# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=turn-rs
pkgver=3.1.0
pkgrel=0
pkgdesc="A pure rust implemented turn server"
url="https://github.com/mycrl/turn-rs"
arch="all !loongarch64" # loongarch64: blocked by libc crate
license="GPL-3.0-only"
makedepends="
	cargo
	cargo-auditable
	protobuf-dev
"
install="turn-rs.pre-install"
subpackages="
	$pkgname-openrc
	$pkgname-doc
"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/mycrl/turn-rs/archive/refs/tags/v$pkgver.tar.gz
	turn-rs.initd
	turn-rs.confd
"
options="net"

prepare() {
	default_prepare
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm 755 target/release/turn-server "$pkgdir"/usr/bin/turn-server
	install -Dm 600 turn-server.toml "$pkgdir"/etc/turn-rs/turn-server.toml

	install -Dm 755 "$srcdir"/turn-rs.initd "$pkgdir"/etc/init.d/turn-rs
	install -Dm 644 "$srcdir"/turn-rs.confd "$pkgdir"/etc/conf.d/turn-rs

	install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
eb5ae9e0e55f6f00da7ba849ef2433b828cb0c6483c61a349a5e535f05410445f0b291cee6e73cc99cba875e3bd2ea4a950cfe9ec5172683ca0fc7e14f4bd7d2  turn-rs-3.1.0.tar.gz
0be3a81c5c9c13e2ba36a867282b3cae90e311d314c6e3f05855ce743fb2457ca12c0b7540e800bfe48a8e2129eb3acc970bc85b9b22dac70648b1637ccfb80f  turn-rs.initd
cc6b17c4efe13d0cc100e20c2d855cb5aa1cb4c7a65ccfa91757f0e667aac77ea020a17fdbcf67ef0de9a32c6133705e1bca2fe239d5ac19234d4de6f425e89e  turn-rs.confd
"
